package service.impl;

import dao.JxbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Jxb;
import service.JxbService;

import java.util.List;

/**
 * 急性病表业务逻辑实现类
 */
@Service
public class JxbServiceImpl implements JxbService {
    @Autowired
    private JxbMapper jxbMapper;

    @Override
    public Jxb findJxbById(Integer id) {
        return jxbMapper.findJxbById(id);
    }

    @Override
    public List<Jxb> findAllJxb() {
        return jxbMapper.findAllJxb();
    }

    @Override
    public List<Jxb> findJxbByCategory(String category) {
        return jxbMapper.findJxbByCategory(category);
    }

    @Override
    public List<Jxb> findJxbBySeason(String season) {
        return jxbMapper.findJxbBySeason(season);
    }

    @Override
    public List<Jxb> searchJxb(String keyword) {
        return jxbMapper.searchJxb(keyword);
    }

    @Override
    public int addJxb(Jxb jxb) {
        // 自动填充默认值
        if (jxb.getViewCount() == null) {
            jxb.setViewCount(0);
        }
        // createTime由数据库自动填充
        return jxbMapper.addJxb(jxb);
    }

    @Override
    public int updateJxb(Jxb jxb) {
        return jxbMapper.updateJxb(jxb);
    }

    @Override
    public int deleteJxb(Integer id) {
        return jxbMapper.deleteJxb(id);
    }

    @Override
    public int incrementViewCount(Integer id) {
        return jxbMapper.incrementViewCount(id);
    }
}